package exercise.day8;

import java.util.Scanner;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: TODO
 * @date 2022/11/5 0:13
 */
public class WY20_twoSortMethod {
    public static boolean isDicSort(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            if(str[i].compareTo(str[i + 1]) > 0){
                return false;
            }
        }
        return true;
    }
    public static boolean isLenSort(String[] str) {
        for (int i = 0; i < str.length - 1; i++) {
            if (str[i].length() > str[i + 1].length()) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        while (in.hasNext()) {
            int n = in.nextInt();
            String[] str = new String[n];
            for (int i = 0; i < n; i++) {
                str[i] = in.next();
            }
            boolean len = isLenSort(str);
            boolean dic = isDicSort(str);

            if(len && dic){
                System.out.println("both");
            } else if (len) {
                System.out.println("lengths");
            } else if(dic) {
                System.out.println("lexicographically");
            } else {
                System.out.println("none");
            }

        }
    }
}
